<?php

namespace app\api\services\user;

use app\api\model\UserCollect;
use app\api\services\BaseServices;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;

class CollectServices extends BaseServices
{
    /**
     * 用户是否收藏商品
     * @param int $goodsId
     * @param int $userid
     * @return bool
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     */
    public static function userIsCollect(int $goodsId, int $userid): bool
    {
        $is_collect = UserCollect::where('store_goods_id', $goodsId)->where('user_id', $userid)->find();
        return !empty($is_collect);

    }
}